package com.ksp.wke.kspc02;
import static com.ksp.com.KSPCOM_BasConst.*;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import javax.servlet.ServletRequest;
import javax.servlet.http.HttpServletRequest;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.ksp.dom.KSPDOM_ResDta;

import net.minidev.json.JSONArray;

@Controller
public class KSPC02Controller {

	@Autowired
	private KSPC02Mapper kspc02Mapper;

	@RequestMapping("/com/KSPC02")
	@ResponseBody
	public KSPDOM_ResDta iniPam(ServletRequest request) {
		HttpServletRequest httpreq = (HttpServletRequest)request;
		String wTchIdn = httpreq.getParameter("TCH_IDN");
		
		Map<String, Object> wPamMap = new HashMap<>();
		wPamMap.put("TCH_IDN", wTchIdn);
		KSPDOM_ResDta wResDta = new KSPDOM_ResDta();
		try {
			wResDta = exeSrv(wPamMap);
		} catch (Exception e) {
			wResDta.setCod("400");
			wResDta.setMsg(e.getMessage());
		}

		return wResDta;
	}

	public KSPDOM_ResDta exeSrv(Map<String, Object> pPamMap) {
		List<Map<String, Object>> wQryQuaDetail = kspc02Mapper.qryQuaDetail(pPamMap);
		return KSPDOM_ResDta.buildSucc(JSONArray.toJSONString(wQryQuaDetail));
	}

}
